<template>
  <div class="product-add">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="200px">
      <!--店员修改-->
      <div class="common-form">招商详情</div>
      <el-form-item label="姓名">
        {{form.name}}
      </el-form-item>
      <el-form-item label="电话" prop="name">
        {{form.phone}}
      </el-form-item>
      <el-form-item label="性别" prop="name">
        <div v-if="form.sex == 1">男</div>
        <div v-if="form.sex == 0">女</div>
      </el-form-item>
      <el-form-item label="从事行业" prop="name">
        {{form.business}}
      </el-form-item>
      <el-form-item label="从事行业时间(年)" prop="name">
        {{form.business_time}}
      </el-form-item>
      <el-form-item label="省" prop="name">
        {{form.province}}
      </el-form-item>
      <el-form-item label="市" prop="name">
        {{form.city}}
      </el-form-item>
      <el-form-item label="区" prop="name">
        {{form.region}}
      </el-form-item>
      <el-form-item label="人口数量(万)" prop="name">
        {{form.population}}
      </el-form-item>
      <el-form-item label="可投入资金(万)" prop="name">
        {{form.capital}}
      </el-form-item>
      <el-form-item label="是否有团队" prop="name">
        <div v-if="form.has_group == 0">无</div>
        <div v-if="form.has_group == 1">有</div>
      </el-form-item>
      <el-form-item label="优势" prop="name">
        {{form.advantage}}
      </el-form-item>
    </el-form>
    <div class="common-button-wrapper">
      <el-button size="small" type="info" @click="cancelFunc">返回</el-button>
    </div>
  </div>
</template>

<script>
import JoinApplyApi from '@/api/joinapply.js';

export default {
  components: {},
  data() {
    return {
      form: {},
      loading: false,
      /*是否上传图片*/
      isupload: false,
      category: [],
    };
  },
  created() {
    if (this.$route.query.id != 0 && this.$route.query.id != undefined) {
      this.form.id = this.$route.query.id;
      this.getParams()
    }
  },

  methods: {
    getParams() {
      let self = this;
      // 取到路由带过来的参数
      JoinApplyApi.edit({
        id: self.form.id
      }, true)
        .then(data => {
          // 将数据放在当前组件的数据内
          self.form = data.data;
        })
        .catch(error => {

        });

    },
    onSubmit() {
      let self = this;
      let form = self.form;
      self.$refs.form.validate((valid) => {
        if (valid) {
          self.loading = true;
          if (this.form.id == '') {
            JoinApplyApi.create(form, true)
              .then(data => {
                self.$message({
                  message: '操作成功',
                  type: 'success'
                });
                self.$router.push('/setting/dic/index');
              })
              .catch(error => {
                self.loading = false;
              });
          } else {
            JoinApplyApi.update(form, true)
              .then(data => {
                self.$message({
                  message: '操作成功',
                  type: 'success'
                });
                self.$router.push('/setting/dic/index');
              })
              .catch(error => {
                self.loading = false;
              });
          }

        }
      });
    },
    /*取消*/
    cancelFunc() {
      this.$router.back(-1);
    },

  }

};
</script>

<style lang="scss" scoped>
.basic-setting-content {
}

.product-add {
  padding-bottom: 50px;
}
</style>
